/*
 * @description:
 * @Author: lal
 * @Date: 2020-05-27 11:11:43
 * @LastEditors: lal
 * @LastEditTime: 2020-05-27 11:19:44
 */

const { ipcMain, dialog } = require("electron");
import fs from "fs";

ipcMain.handle("save-dialog", async (event, { name, value }) => {
  const result = await dialog.showSaveDialog({
    defaultPath: name,
  });
  if (result.canceled === false) {
    await fs.writeFileSync(result.filePath, new Uint8Array(Buffer.from(value)));
  }
});
